<%--
  Created by IntelliJ IDEA.
  User: 86175
  Date: 2021/8/2
  Time: 10:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新建账户</title>
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script>
        function ckName(){
            var name = document.getElementById("accountName").value;
            var nameReg = /^[\u4e00-\u9fa5]{2,4}$/;
            var flag;
            if (nameReg.test(name)){
                document.getElementById("nameTip").innerText="";
                flag = true;
            }else {
                document.getElementById("nameTip").innerText="请输入2-4位汉字";
                document.getElementById("nameTip").style="color:red";
                flag=false;
            }
            return flag;
        }
        function ckPsw(){
            var psw = document.getElementById("accountPsw").value;
            var pswReg = /^[A-z0-9]{6,20}$/;
            var flag;
            if (pswReg.test(psw)){
                document.getElementById("pswTip").innerText="";
                flag = true;
            }else {
                document.getElementById("pswTip").innerText="请输入正确的密码格式";
                document.getElementById("pswTip").style="color:red";
                flag=false;
            }
            return flag;
        }
        function ckNo(){
            var no = document.getElementById("accountNo").value;
            var noReg = /^\d{8}$/;
            var flag;
            if (noReg.test(no)){
                document.getElementById("noTip").innerText="";
                flag = true;
            }else {
                document.getElementById("noTip").innerText="请输入8位数字的账号";
                document.getElementById("noTip").style="color:red";
                flag=false;
            }
            return flag;
        }
        function ckBank(){
            var bank = document.getElementById("accountBank").value;
            var bankReg = /^[\u4e00-\u9fa5]{4,8}$/;
            var flag;
            if (bankReg.test(bank)){
                document.getElementById("bankTip").innerText="";
                flag = true;
            }else {
                document.getElementById("bankTip").innerText="请输入4-8位汉字";
                document.getElementById("bankTip").style="color:red";
                flag=false;
            }
            return flag;
        }
        function ckAll(){
            return ckName() && ckBank() && ckNo() && ckPsw();
        }

    </script>
</head>
<body>
<div class="container">
    <h2>新开户</h2>
    <form action="AddAccountServlet" method="post" onsubmit="return ckAll(this)">
        户名<input type="text" onblur="ckName()" id="accountName" name="accountName" placeholder="请输入户名" class="form-control">
        <span id="nameTip"></span><br>
        密码<input type="password" placeholder="密码由字母、数字构成，可以是数字和字母的组合，6-20个字符" onblur="ckPsw()" id="accountPsw" name="accountPsw" class="form-control">
        <span id="pswTip"></span><br>
        账号<input type="text" onblur="ckNo()" id="accountNo" name="accountNo" class="form-control">
        <span id="noTip"></span><br>
        开户行<input type="text" onblur="ckBank()" id="bank" name="bank" class="form-control">
        <span id="bankTip"></span><br>
        <input type="submit" value="新开户" class="btn-primary">
        <a href="FindAllAccountServlet">显示所有账户</a>
    </form>

</div>
</body>
</html>
